package com.gemini.main.authentication.handler;

import com.alibaba.fastjson.JSON;
import com.gemini.main.common.bean.ResultGenerator;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Wisdytech.cn
 * com.gemini.main.authentication.handler.GeminiLogoutSuccessHandler
 *
 * @author hailin.zhl
 * @date 2018/12/04
 */
@Component
public class GeminiLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        response.setContentType("application/json;charset=utf-8");
        response
                .getWriter()
                .write(JSON.toJSONString(ResultGenerator.genSuccessResult()));
    }
}
